package com.phiture.erp.basic.web.controller.api;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import com.phiture.erp.basic.api.pojo.resp.ErpCustomerResp;
import com.phiture.erp.basic.api.pojo.resp.ErpMaterialUnitResp;
import com.phiture.erp.basic.api.service.ErpMaterialUnitApi;
import com.phiture.erp.basic.core.service.ErpMaterialUnitService;
import com.phiture.erp.basic.dal.entity.ErpMaterialUnitDO;
import com.phiture.erp.basic.web.convert.ErpCustomerConvertMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;

@Service
@RequiredArgsConstructor
public class ErpMaterialUnitApiServiceImpl implements ErpMaterialUnitApi {

    private final ErpMaterialUnitService erpMaterialUnitService;


    @Override
    public ErpMaterialUnitResp getMaterialUnit(Long id) {
        return null;
    }

    @Override
    public List<ErpMaterialUnitResp> getMaterialUnitListByStatus(Integer status) {
        return null;
    }

    @Override
    public List<ErpMaterialUnitResp> getMaterialUnitList(Collection<Long> ids) {
        return null;
    }

    @Override
    public Map<Long, ErpMaterialUnitResp> getMaterialUnitMap(Collection<Long> ids) {
        Map<Long, ErpMaterialUnitDO> unitDOMap = erpMaterialUnitService.getMaterialUnitMap(ids);
        // 将 ErpMaterialUnitDO 转换为 ErpMaterialUnitResp

        return unitDOMap.entrySet().stream()
                .collect(Collectors.toMap(
                        Map.Entry::getKey,
                        entry -> {
                            ErpMaterialUnitDO unitDO = entry.getValue();
                            ErpMaterialUnitResp unitResp = new ErpMaterialUnitResp();
                            unitResp.setId(unitDO.getId());
                            unitResp.setName(unitDO.getName());
                            unitResp.setStatus(unitDO.getStatus());
                            // 继续添加其他属性的赋值
                            return unitResp;
                        }
                ));
    }
}
